Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tools/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["denoland.vscode-deno"]
}
4 changes: 1 addition & 3 deletions tools/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
"inspector/promises",
"inspector"
],
"files.watcherExclude": {
"**/node_modules/**": true,
},
"deno.enable": true
}
30 changes: 30 additions & 0 deletions tools/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"workspace": [
"./packages/bench",
"./packages/mini-parse",
"./packages/wesl",
"./packages/wesl-link",
"./packages/wesl-packager",
"./packages/wesl-plugin",
"./packages/wesl-reflect",
"./packages/wesl-tooling"
],
"exclude": [
"./examples",
"./scripts",
"packages/plugin-test",
"packages/random_wgsl",
"packages/test_pkg",
"**/dist/**"
],
"compilerOptions": {
"strict": true,
"lib": ["deno.ns", "dom", "dom.iterable"],
"types": ["@webgpu/types"]
},
"lint": {
"rules": {
"exclude": ["no-explicit-any"]
}
}
}
1 change: 1 addition & 0 deletions tools/packages/bench/bin/bench.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "node:path";
import process from "node:process";
import { link } from "wesl";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
Expand Down
1 change: 1 addition & 0 deletions tools/packages/bench/bin/choose_baseline.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { execSync } from "node:child_process";
import { existsSync, mkdirSync, rmSync } from "node:fs";
import path from "node:path";
import process from "node:process";

/**
* a node script get an earlier copy of the repo as a baseline for benchmark comparisons
Expand Down
1 change: 1 addition & 0 deletions tools/packages/bench/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 3 additions & 2 deletions tools/packages/bench/src/LoadSimpleTest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { exit } from "node:process";
import * as simpleTests from "../src/experiments/SimpleTests.ts";
import { loadBenchmarkFiles } from "../src/LoadBenchmarks.ts";

Expand All @@ -9,7 +10,7 @@ export interface SimpleTest {
export function loadSimpleTest(simpleSelect: string | undefined): SimpleTest {
if (!simpleSelect) {
console.error("No test name prefix provided for --simple");
process.exit(1);
exit(1);
}

const testEntry = Object.entries(simpleTests).find(([name]) =>
Expand All @@ -21,7 +22,7 @@ export function loadSimpleTest(simpleSelect: string | undefined): SimpleTest {
`No test found with prefix '${simpleSelect}' in SimpleTests.ts`,
);
console.error(`Available tests: ${Object.keys(simpleTests).join(", ")}`);
process.exit(1);
exit(1);
}
const [name, fn] = testEntry;
return { name, fn };
Expand Down
5 changes: 3 additions & 2 deletions tools/packages/bench/src/experiments/BenchManually.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as process from "node:process";
import { _linkSync, type link } from "wesl";
import type { BenchTest } from "../../bin/bench.ts";
import { diffPercent } from "../table-util/Formatters.ts";
Expand All @@ -7,8 +8,8 @@ export function benchManually(
tests: BenchTest[],
baselineLink: typeof link,
): void {
const gc = globalThis.gc || (() => {});
console.log("gc is", globalThis.gc ? "enabled" : "disabled");
const gc = (globalThis as any).gc || (() => {});
console.log("gc is", (globalThis as any).gc ? "enabled" : "disabled");
for (const test of tests) {
const weslSrc = Object.fromEntries(test.files.entries());
const rootModuleName = test.mainFile;
Expand Down
5 changes: 3 additions & 2 deletions tools/packages/bench/src/mitata-util/MitataBench.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type PerformanceEntry, PerformanceObserver } from "node:perf_hooks";
import * as process from "node:process";
import type * as mitataCountersType from "@mitata/counters";
import { measure } from "mitata";
import {
Expand Down Expand Up @@ -156,7 +157,7 @@ async function getHeapFn(): Promise<() => number> {

/** fetch the runtime's function to call gc() manually */
function gcFunction(): () => void {
const gc = globalThis.gc || (globalThis as any).__gc;
const gc = (globalThis as any).gc || (globalThis as any).__gc;
if (gc) return gc;
console.warn(
"MitataBench: gc() not available, run node/bun with --expose-gc",
Expand Down Expand Up @@ -188,6 +189,6 @@ function analyzeGCEntries(
return { inRun, before, after, total, collects };
}

async function wait(msec = 0): Promise<void> {
function wait(msec = 0): Promise<void> {
return new Promise(resolve => setTimeout(resolve, msec));
}
1 change: 1 addition & 0 deletions tools/packages/bench/src/mitata-util/MitataStats.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-types="./Mitata.d.ts"
import type { CpuCounts } from "@mitata/counters";
import type { MeasureResult } from "./MitataBench.ts";
import { mapValues } from "./Util.ts";
Expand Down
1 change: 1 addition & 0 deletions tools/packages/mini-parse/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion tools/packages/mini-parse/src/stream/CachingStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Cache<K, V> extends Map<K, V> {
this.max = max;
}

set(k: K, v: V): this {
override set(k: K, v: V): this {
if (this.size > this.max) {
const first = this.keys().next().value;
if (first) this.delete(first);
Expand Down
2 changes: 1 addition & 1 deletion tools/packages/mini-parse/src/test/RegexMatchers.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { RegexMatchers } from "../stream/MatchersStream";
import { RegexMatchers } from "../stream/MatchersStream.ts";

test("token matcher", () => {
const m = new RegexMatchers({
Expand Down
1 change: 0 additions & 1 deletion tools/packages/mini-parse/test-util.vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { resolve } from "node:path";
/// <reference types="vitest/config" />
import { defineConfig, type LibraryOptions } from "vite";
import { baseViteConfig } from "./base.vite.config.ts";

Expand Down
1 change: 0 additions & 1 deletion tools/packages/mini-parse/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="vitest" />
import { defineConfig, type LibraryOptions } from "vite";
import { baseViteConfig } from "./base.vite.config.ts";

Expand Down
1 change: 0 additions & 1 deletion tools/packages/mini-parse/vitest-util.vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { resolve } from "node:path";
/// <reference types="vitest/config" />
import { defineConfig, type LibraryOptions } from "vite";
import { baseViteConfig } from "./base.vite.config.ts";

Expand Down
1 change: 0 additions & 1 deletion tools/packages/plugin-test/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="vitest/config" />
import path from "node:path";
import { fileURLToPath } from "node:url";
import type { Plugin, UserConfig } from "vite";
Expand Down
1 change: 1 addition & 0 deletions tools/packages/wesl-link/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 2 additions & 1 deletion tools/packages/wesl-link/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "node:path";
import { cwd } from "node:process";
import { pathToFileURL } from "node:url";
import { enableTracing, log } from "mini-parse";
import { astToString, link, scopeToString } from "wesl";
Expand Down Expand Up @@ -70,7 +71,7 @@ async function parseArgs(args: string[]) {

async function linkNormally(argv: CliArgs): Promise<void> {
const { baseDir, projectDir, rootModule: rootModuleName } = argv;
const weslRoot = baseDir || process.cwd();
const weslRoot = baseDir || cwd();
const weslSrc = await loadModules(projectDir, weslRoot, argv.src);
const projectDirAbs = path.resolve(projectDir, "src.js");
const projectDirUrl = pathToFileURL(projectDirAbs);
Expand Down
3 changes: 2 additions & 1 deletion tools/packages/wesl-link/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
import { argv } from "node:process";
import { hideBin } from "yargs/helpers";
import { cli } from "./cli.ts";

const rawArgs = hideBin(process.argv);
const rawArgs = hideBin(argv);

cli(rawArgs);
1 change: 1 addition & 0 deletions tools/packages/wesl-packager/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions tools/packages/wesl-packager/src/PackageWesl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import path from "node:path";
import { Biome, Distribution } from "@biomejs/js-api";
import { noSuffix, type WeslBundle } from "wesl";
import { loadModules, parseDependencies, zip } from "wesl-tooling";
// Ideally this would use an import attribute instead of this Vite+Deno bodge
// @ts-types="vite/client"
import weslBundleDecl from "../../wesl/src/WeslBundle.ts?raw";
import type { CliArgs } from "./PackagerCli.ts";

Expand Down
3 changes: 3 additions & 0 deletions tools/packages/wesl-plugin/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"exclude": ["test/**"]
}
2 changes: 1 addition & 1 deletion tools/packages/wesl-plugin/src/plugins/farm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createFarmPlugin } from "unplugin";
import { weslPlugin } from "../WeslPlugin";
import { weslPlugin } from "../WeslPlugin.ts";

export default createFarmPlugin(weslPlugin);
6 changes: 3 additions & 3 deletions tools/packages/wesl-plugin/src/plugins/nuxt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
import type { WeslPluginOptions } from "../WeslPluginOptions";
import vite from "./vite";
import webpack from "./webpack";
import type { WeslPluginOptions } from "../WeslPluginOptions.ts";
import vite from "./vite.ts";
import webpack from "./webpack.ts";
import "@nuxt/schema";

type ModuleOptions = WeslPluginOptions;
Expand Down
1 change: 1 addition & 0 deletions tools/packages/wesl-reflect/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
6 changes: 5 additions & 1 deletion tools/packages/wesl-reflect/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
/** @hidden */
declare module "*?simple_reflect" {
export const structs: WeslStruct[];
/**
* Need to put the import here for it to augment the global scope
* https://stackoverflow.com/a/51114250/3492994
*/
export const structs: import("./SimpleReflectExtension.ts").WeslStruct[];
}
3 changes: 1 addition & 2 deletions tools/packages/wesl-reflect/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/// <reference types="vitest/config" />
import path from "node:path";
import { fileURLToPath } from "node:url";
import type { UserConfig } from "vite";
import viteWesl from "../wesl-plugin/src/plugins/vite";
import viteWesl from "../wesl-plugin/src/plugins/vite.ts";
import { simpleReflect } from "./src/SimpleReflectExtension.ts";

const thisPath = fileURLToPath(import.meta.url);
Expand Down
1 change: 1 addition & 0 deletions tools/packages/wesl-tooling/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion tools/packages/wesl-tooling/test/ParseDependencies.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect, test } from "vitest";
import { parseDependencies } from "../src/ParseDependencies.ts";

const thisDir = import.meta.dirname;
const thisDir = import.meta.dirname!;

test("parseDepenencies finds non-root dependency", () => {
const srcs = {
Expand Down
1 change: 0 additions & 1 deletion tools/packages/wesl/base.vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="vitest/config" />
import { resolve } from "node:path";
import type { UserConfig } from "vite";
import dts from "vite-plugin-dts";
Expand Down
1 change: 1 addition & 0 deletions tools/packages/wesl/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 0 additions & 1 deletion tools/packages/wesl/sizetest.vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { resolve } from "node:path";
/// <reference types="vitest/config" />
import { defineConfig, type LibraryOptions } from "vite";
import { baseViteConfig } from "./base.vite.config.ts";

Expand Down
2 changes: 1 addition & 1 deletion tools/packages/wesl/src/ClickableError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function throwClickableError(params: ClickableErrorParams): void {
let oldLimit = 0;
// Supported on Chrome https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/stackTraceLimit
if ("stackTraceLimit" in Error) {
oldLimit = Error.stackTraceLimit;
oldLimit = Error.stackTraceLimit as any as number;
Error.stackTraceLimit = 1;
}

Expand Down
6 changes: 3 additions & 3 deletions tools/packages/wesl/src/LinkedWesl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { SrcMap } from "mini-parse";
import { assertThatDebug } from "./Assertions.ts";
import { errorHighlight, offsetToLineNumber } from "./Util.ts";
import type { WeslDevice } from "./WeslDevice";
import type { WeslDevice } from "./WeslDevice.ts";

/** Results of shader compilation. Has {@link WeslGPUCompilationMessage}
* which are aware of the WESL module that an error was thrown from. */
Expand Down Expand Up @@ -109,7 +109,7 @@ export class LinkedWesl {
compilationInfo: GPUCompilationInfo,
): WeslGPUCompilationInfo {
return {
__brand: compilationInfo.__brand,
__brand: "GPUCompilationInfo",
messages: compilationInfo.messages.map(v =>
this.mapGPUCompilationMessage(v),
),
Expand All @@ -134,7 +134,7 @@ export class LinkedWesl {
);

return {
__brand: message.__brand,
__brand: "GPUCompilationMessage",
type: message.type,
message: message.message,
offset: srcPosition.position,
Expand Down
2 changes: 1 addition & 1 deletion tools/packages/wesl/src/WeslDevice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { throwClickableError } from "./ClickableError.ts";
import type { ExtendedGPUValidationError } from "./LinkedWesl";
import type { ExtendedGPUValidationError } from "./LinkedWesl.ts";

/**
* We want the WebGPU compilation errors to point at WESL code.
Expand Down
2 changes: 1 addition & 1 deletion tools/packages/wesl/src/parse/WeslBaseGrammar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { kind, or, withSepPlus } from "mini-parse";
import type { WeslTokenKind } from "./WeslStream";
import type { WeslTokenKind } from "./WeslStream.ts";

export const word = kind<WeslTokenKind>("word");
export const keyword = kind<WeslTokenKind>("keyword");
Expand Down
2 changes: 1 addition & 1 deletion tools/packages/wesl/src/test/Tokenizer.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { WeslStream, type WeslToken } from "../parse/WeslStream";
import { WeslStream, type WeslToken } from "../parse/WeslStream.ts";

test("tokenize empty string", () => {
const tokenizer = new WeslStream("");
Expand Down
5 changes: 2 additions & 3 deletions tools/packages/wesl/src/test/WeslDevice.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { setTimeout } from "node:timers";
import { SrcMap } from "mini-parse";
import { expect, test, vi } from "vitest";
import { LinkedWesl } from "../LinkedWesl";
import { makeWeslDevice } from "../WeslDevice";
import { LinkedWesl } from "../LinkedWesl.ts";
import { makeWeslDevice } from "../WeslDevice.ts";

test("WeslDevice doesn't conflict with uncapturederror", async () => {
const GPUDeviceMock = vi.fn(function (this: GPUDevice) {
Expand Down
1 change: 0 additions & 1 deletion tools/packages/wesl/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="vitest/config" />
import { defineConfig } from "vite";
import { baseViteConfig } from "./base.vite.config.ts";

Expand Down
1 change: 0 additions & 1 deletion tools/packages/wesl/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="vitest/config" />
import { mergeConfig } from "vite";
import { baseViteConfig } from "./base.vite.config.ts";

Expand Down
7 changes: 5 additions & 2 deletions tools/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "ES2024", // we can expect a modern version with WebGPU (but we want stablility, so not "esnext")
"lib": ["ES2024"],
/* We're running in both in Node.js and browsers, but we have to pick one of them for type checking */
"lib": ["ES2024", "DOM"],

"noEmit": true, // we don't transpile with tsgo, we just typecheck

Expand All @@ -23,8 +24,10 @@
/* strictness in TypeScript */
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
"noUncheckedSideEffectImports": true,
// "noUncheckedIndexedAccess": true // maybe later, some lint to fix first
"types": []
},
"include": [],
"exclude": ["**/node_modules", "**/dist"]
}
9 changes: 5 additions & 4 deletions tools/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"types": ["node", "@webgpu/types"],
"target": "ESNext", // we presume that dev machines are up to date
"lib": ["ESNext"]
}
"lib": ["ESNext"],
"types": ["@types/node", "@webgpu/types"],
"target": "ESNext" // we presume that dev machines are up to date
},
"include": []
}