Skip to content

Commit

Permalink
Add tests using Svelte 5 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
sockmaster27 committed Oct 31, 2024
1 parent 632e955 commit 2e61fc2
Show file tree
Hide file tree
Showing 104 changed files with 1,872 additions and 132 deletions.
151 changes: 151 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
"scripts": {
"package": "cd packages/svader && npm run package",
"dev:v4": "npm run package && cd packages/tests-svelte4 && npm run dev",
"preview:v4": "npm run package && cd packages/tests-svelte4 && npm run preview",
"check": "npm run package && npm run check:formatting && npm run check:svader && npm run check:tests-svelte4",
"dev:v5": "npm run package && cd packages/tests-svelte5 && npm run dev",
"preview:v4": "cd packages/tests-svelte4 && npm run preview",
"preview:v5": "cd packages/tests-svelte5 && npm run preview",
"check": "npm run package && npm run check:formatting && npm run check:svader && npm run check:v4 && npm run check:v5",
"check:formatting": "prettier . --check",
"check:svader": "cd packages/svader && npm run check",
"check:tests-svelte4": "cd packages/tests-svelte4 && npm run check",
"build": "npm run package && npm run build:tests-svelte4",
"build:tests-svelte4": "cd packages/tests-svelte4 && npm run build",
"test": "playwright test"
"check:v4": "cd packages/tests-svelte4 && npm run check",
"check:v5": "cd packages/tests-svelte5 && npm run check",
"build": "npm run package && npm run build:v4 && npm run build:v5",
"build:v4": "cd packages/tests-svelte4 && npm run build",
"build:v5": "cd packages/tests-svelte5 && npm run build",
"test": "npm run package && playwright test"
},
"devDependencies": {
"@playwright/test": "^1.48.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/tests-svelte4/src/routes/remount/webgl/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import shaderCode from "./shader.frag?raw";
let show = true;
// async function f() {
// while (true) {
// show = !show;
// await new Promise(resolve => requestIdleCallback(resolve));
// }
// }
// if (typeof window !== "undefined") f();
</script>

<label for="show">Show</label>
Expand Down
4 changes: 4 additions & 0 deletions packages/tests-svelte4/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ import { defineConfig } from "vite";

export default defineConfig({
plugins: [sveltekit()],
preview: {
port: 4173,
strictPort: true,
},
});
23 changes: 23 additions & 0 deletions packages/tests-svelte5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "tests-svelte5",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite build && vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"typescript": "^5.0.0",
"vite": "^5.0.11"
},
"svelte": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module"
}
13 changes: 13 additions & 0 deletions packages/tests-svelte5/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}

export {};
12 changes: 12 additions & 0 deletions packages/tests-svelte5/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover" style="margin: 0">
<div>%sveltekit.body%</div>
</body>
</html>
1 change: 1 addition & 0 deletions packages/tests-svelte5/src/routes/+layout.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const trailingSlash = "always";
9 changes: 9 additions & 0 deletions packages/tests-svelte5/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ol>
<li><a href="hello-world/">Hello world</a></li>
<li><a href="remount/">Remounting canvas</a></li>
<li><a href="oversized-canvas/">Oversized canvas</a></li>
<li><a href="logo/">Logo</a></li>
<li><a href="landing-page-bubbles/">Landing page with bubbles</a></li>
<li><a href="landing-page-halo/">Landing page with a halo</a></li>
<li><a href="slider/">Slider component</a></li>
</ol>
4 changes: 4 additions & 0 deletions packages/tests-svelte5/src/routes/hello-world/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ul>
<li><a href="webgl/">WebGL</a></li>
<li><a href="webgpu/">WebGPU</a></li>
</ul>
22 changes: 22 additions & 0 deletions packages/tests-svelte5/src/routes/hello-world/webgl/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script>
import { WebGlShader } from "svader";
import shaderCode from "./shader.frag?raw";
</script>

<WebGlShader
width="500px"
height="500px"
code={shaderCode}
parameters={[
{
name: "u_resolution",
value: "resolution",
},
{
name: "u_offset",
value: "offset",
},
]}
>
<div class="fallback">WebGL not supported in this environment.</div>
</WebGlShader>
13 changes: 13 additions & 0 deletions packages/tests-svelte5/src/routes/hello-world/webgl/shader.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#version 300 es

precision mediump float;
out vec4 fragColor;

uniform vec2 u_resolution;
uniform vec2 u_offset;

void main() {
vec2 pos = gl_FragCoord.xy + u_offset;
vec2 st = pos / u_resolution;
fragColor = vec4(st, 0.0, 1.0);
}
24 changes: 24 additions & 0 deletions packages/tests-svelte5/src/routes/hello-world/webgpu/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script>
import { WebGpuShader } from "svader";
import shaderCode from "./shader.wgsl?raw";
</script>

<WebGpuShader
width="500px"
height="500px"
code={shaderCode}
parameters={[
{
label: "Resolution",
binding: 0,
value: "resolution",
},
{
label: "Offset",
binding: 1,
value: "offset",
},
]}
>
<div class="fallback">WebGPU not supported in this environment.</div>
</WebGpuShader>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@group(0) @binding(0) var<uniform> resolution: vec2f;
@group(0) @binding(1) var<uniform> offset: vec2f;

@fragment
fn main(@builtin(position) raw_pos: vec4f) -> @location(0) vec4f {
let pos = raw_pos.xy + offset;
let st = pos / resolution;
return vec4f(st, 0.0, 1.0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ul>
<li><a href="webgl/">WebGL</a></li>
<li><a href="webgpu/">WebGPU</a></li>
</ul>
Loading

0 comments on commit 2e61fc2

Please sign in to comment.