@skathi-native/cli 0.1.0-beta.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aot-inputs.ts +21 -2
- package/build.ts +241 -60
- package/check/bundle.ts +265 -0
- package/check/graph.ts +3 -1
- package/check/index.ts +10 -1
- package/check/program.ts +26 -6
- package/cli/create.ts +29 -7
- package/devtools/commands.ts +25 -0
- package/effects/compile.ts +160 -31
- package/effects/sk.slang +353 -29
- package/package.json +7 -4
- package/prod.ts +40 -7
- package/svelte.ts +76 -0
- package/templates/icon.png +0 -0
- package/templates/showcase/assets/textures/golden.png +0 -0
- package/templates/showcase/assets/textures/hammered.png +0 -0
- package/templates/showcase/assets/textures/noir.png +0 -0
- package/templates/showcase/assets/textures/reeded.png +0 -0
- package/templates/showcase/assets/textures/teal-orange.png +0 -0
- package/templates/showcase/shaders/dissolve.slang +40 -0
- package/templates/showcase/shaders/fireflies.slang +58 -0
- package/templates/showcase/shaders/glass.slang +31 -0
- package/templates/showcase/shaders/grade.slang +34 -0
- package/templates/showcase/shaders/halftone.slang +42 -0
- package/templates/showcase/shaders/lens.slang +51 -0
- package/templates/showcase/shaders/nebula.slang +57 -0
- package/templates/showcase/shaders/orbit.slang +52 -0
- package/templates/showcase/shaders/pond.slang +76 -0
- package/templates/showcase/shaders/ripples.slang +71 -0
- package/templates/showcase/shaders/shatter.slang +116 -0
- package/templates/showcase/shaders/snow.slang +57 -0
- package/templates/showcase/shaders/spotlight.slang +52 -0
- package/templates/showcase/src/App.vue +11 -16
- package/templates/showcase/src/components/FullWindow.vue +77 -0
- package/templates/showcase/src/components/Page.vue +2 -0
- package/templates/showcase/src/fullwindow.ts +36 -0
- package/templates/showcase/src/icons.ts +2 -0
- package/templates/showcase/src/pages/GraphicsPage.vue +122 -0
- package/templates/showcase/src/pages/MotionPage.vue +71 -1
- package/templates/showcase/src/pages/ShadersPage.vue +443 -0
- package/templates/showcase/src/router.ts +32 -1
- package/templates/svelte/.vscode/settings.json +3 -0
- package/templates/svelte/assets/hello.txt +1 -0
- package/templates/svelte/src/App.svelte +142 -0
- package/templates/svelte/src/main.ts +4 -0
- package/vitecompat.ts +2 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, shallowRef } from "vue";
|
|
3
|
+
import Card from "../components/Card.vue";
|
|
4
|
+
import Page from "../components/Page.vue";
|
|
5
|
+
import { fullWindow, shatter } from "../fullwindow";
|
|
6
|
+
|
|
7
|
+
const LENS_WIDTH = 220;
|
|
8
|
+
const scene = shallowRef<HTMLElement | null>(null);
|
|
9
|
+
const lensX = ref(48);
|
|
10
|
+
let grab: number | null = null;
|
|
11
|
+
const lensDown = (e: MouseEvent) => (grab = e.clientX - lensX.value);
|
|
12
|
+
const lensUp = () => (grab = null);
|
|
13
|
+
function lensMove(e: MouseEvent) {
|
|
14
|
+
if (grab === null || !scene.value) return;
|
|
15
|
+
const room = scene.value.getBoundingClientRect().width - LENS_WIDTH;
|
|
16
|
+
lensX.value = Math.min(Math.max(e.clientX - grab, 0), room);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const warm = ref(false);
|
|
20
|
+
|
|
21
|
+
const burnt = ref(false);
|
|
22
|
+
|
|
23
|
+
const cells = [6, 9, 14];
|
|
24
|
+
const cell = ref(9);
|
|
25
|
+
const halftone = computed(() => `halftone(${cell.value}px, 0.125, 1, #0b0b12)`);
|
|
26
|
+
|
|
27
|
+
const grades = [
|
|
28
|
+
{ id: "teal-orange", label: "Teal & orange" },
|
|
29
|
+
{ id: "noir", label: "Noir" },
|
|
30
|
+
{ id: "golden", label: "Golden hour" },
|
|
31
|
+
];
|
|
32
|
+
const lut = ref("teal-orange");
|
|
33
|
+
const graded = ref(true);
|
|
34
|
+
const grade = computed(() => `grade(url(assets/textures/${lut.value}.png), ${graded.value ? 1 : 0})`);
|
|
35
|
+
const pickGrade = (id: string) => {
|
|
36
|
+
lut.value = id;
|
|
37
|
+
graded.value = true;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const patterns = [
|
|
41
|
+
{ id: "reeded", label: "Reeded", depth: 14, scale: 1.4 },
|
|
42
|
+
{ id: "hammered", label: "Hammered", depth: 10, scale: 1 },
|
|
43
|
+
];
|
|
44
|
+
const pattern = ref(patterns[0]!);
|
|
45
|
+
const glass = computed(
|
|
46
|
+
() => `glass(url(assets/textures/${pattern.value.id}.png), ${pattern.value.depth}px, ${pattern.value.scale})`,
|
|
47
|
+
);
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<Page
|
|
52
|
+
title="Shaders"
|
|
53
|
+
lead="Each effect is one Slang file in shaders/, compiled into the app for DirectX, Vulkan and Metal, and applied with a CSS custom property. Each of these uses a different part of the effect API."
|
|
54
|
+
>
|
|
55
|
+
<Card title="Over the whole window" api="shatter · ripples · snow · fireflies">
|
|
56
|
+
<div class="row">
|
|
57
|
+
<button class="btn" :disabled="fullWindow.shatter !== null" @click="shatter($event.clientX, $event.clientY)">
|
|
58
|
+
Shatter
|
|
59
|
+
</button>
|
|
60
|
+
<button class="btn" :class="{ on: fullWindow.ripples }" @click="fullWindow.ripples = !fullWindow.ripples">
|
|
61
|
+
Ripples
|
|
62
|
+
</button>
|
|
63
|
+
<button class="btn" :class="{ on: fullWindow.snow }" @click="fullWindow.snow = !fullWindow.snow">Snow</button>
|
|
64
|
+
<button class="btn" :class="{ on: fullWindow.fireflies }" @click="fullWindow.fireflies = !fullWindow.fireflies">
|
|
65
|
+
Fireflies
|
|
66
|
+
</button>
|
|
67
|
+
</div>
|
|
68
|
+
<p class="faint">
|
|
69
|
+
Layers over the window that take no clicks. Shatter breaks a snapshot of the window into falling shards and puts
|
|
70
|
+
it back, the cracks and gaps letting through what is behind the window. With ripples on, a click anywhere sends
|
|
71
|
+
out a ring of water that bends the window, and rings that meet interfere. Snow parts around the pointer;
|
|
72
|
+
fireflies drift towards it.
|
|
73
|
+
</p>
|
|
74
|
+
</Card>
|
|
75
|
+
|
|
76
|
+
<Card title="Liquid glass" api="lens · [SkBackdrop]">
|
|
77
|
+
<div ref="scene" class="scene" @mousemove="lensMove" @mouseup="lensUp" @mouseleave="lensUp">
|
|
78
|
+
<div class="blob b1" />
|
|
79
|
+
<div class="blob b2" />
|
|
80
|
+
<div class="blob b3" />
|
|
81
|
+
<div class="word">refraction</div>
|
|
82
|
+
<div class="lens" :style="{ left: `${lensX}px` }" @mousedown="lensDown">drag me</div>
|
|
83
|
+
</div>
|
|
84
|
+
<p class="faint">
|
|
85
|
+
Reads the backdrop at displaced coordinates: the rim bends what is behind it, red and blue by different amounts,
|
|
86
|
+
and catches a specular highlight.
|
|
87
|
+
</p>
|
|
88
|
+
</Card>
|
|
89
|
+
|
|
90
|
+
<Card title="Nebula" api="nebula · [SkAnimated] · transition">
|
|
91
|
+
<div class="nebula" :class="{ warm }" @click="warm = !warm">
|
|
92
|
+
<span class="hint">click to shift the palette</span>
|
|
93
|
+
</div>
|
|
94
|
+
<p class="faint">
|
|
95
|
+
Noise sampled at coordinates warped by more noise, redrawn every frame. A CSS transition on --shading blends the
|
|
96
|
+
palette while it moves.
|
|
97
|
+
</p>
|
|
98
|
+
</Card>
|
|
99
|
+
|
|
100
|
+
<Card title="Orbit" api="orbit · [SkBleed]">
|
|
101
|
+
<div class="row orbits">
|
|
102
|
+
<div class="orbit-card">card</div>
|
|
103
|
+
<button class="orbit-pill">Get started</button>
|
|
104
|
+
<div class="orbit-ring">ring</div>
|
|
105
|
+
</div>
|
|
106
|
+
<p class="faint">
|
|
107
|
+
Light running along the rounded border. The halo parameter grows the drawn area, so the glow spills past the
|
|
108
|
+
element's own box.
|
|
109
|
+
</p>
|
|
110
|
+
</Card>
|
|
111
|
+
|
|
112
|
+
<Card title="Halftone" api="halftone · backdrop per cell">
|
|
113
|
+
<div class="print">
|
|
114
|
+
<img class="photo" src="assets/media/aurora.png" alt="Aurora" />
|
|
115
|
+
<div class="screen" :style="{ '--shading': halftone }" />
|
|
116
|
+
</div>
|
|
117
|
+
<div class="row">
|
|
118
|
+
<button v-for="c in cells" :key="c" class="btn" :class="{ on: cell === c }" @click="cell = c">{{ c }}px</button>
|
|
119
|
+
<span class="faint">Re-screens the image under the right half as print dots.</span>
|
|
120
|
+
</div>
|
|
121
|
+
</Card>
|
|
122
|
+
|
|
123
|
+
<Card title="Burn away" api="dissolve · [SkContent] · transition">
|
|
124
|
+
<div class="row">
|
|
125
|
+
<div class="ticket" :class="{ burnt }">
|
|
126
|
+
<img class="ticket-photo" src="assets/media/aurora.png" alt="Aurora" />
|
|
127
|
+
<div class="ticket-text">
|
|
128
|
+
<strong>Northern lights</strong>
|
|
129
|
+
<span>Admit one · row 12</span>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
<button class="btn" @click="burnt = !burnt">{{ burnt ? "Restore" : "Burn" }}</button>
|
|
133
|
+
</div>
|
|
134
|
+
<p class="faint">
|
|
135
|
+
Shades the element's own painting, image and text included. A transition on --shading moves the burning edge
|
|
136
|
+
across it.
|
|
137
|
+
</p>
|
|
138
|
+
</Card>
|
|
139
|
+
|
|
140
|
+
<Card title="Pond" api="pond · [SkContent] · [SkHistory] · [SkPointer]">
|
|
141
|
+
<div class="pond">
|
|
142
|
+
<img class="pond-photo" src="assets/media/aurora.png" alt="Aurora" />
|
|
143
|
+
<span class="pond-word">still water</span>
|
|
144
|
+
</div>
|
|
145
|
+
<p class="faint">
|
|
146
|
+
Drag the pointer across. The water is a wave equation the effect steps in its own state from frame to frame, and
|
|
147
|
+
it bends and lights the element's painting under it.
|
|
148
|
+
</p>
|
|
149
|
+
</Card>
|
|
150
|
+
|
|
151
|
+
<Card title="Colour grade" api="grade · SkTexture · url()">
|
|
152
|
+
<div class="print">
|
|
153
|
+
<img class="photo" src="assets/media/aurora.png" alt="Aurora" />
|
|
154
|
+
<div class="graded" :style="{ '--shading': grade }" />
|
|
155
|
+
</div>
|
|
156
|
+
<div class="row">
|
|
157
|
+
<button class="btn" :class="{ on: !graded }" @click="graded = false">Original</button>
|
|
158
|
+
<button
|
|
159
|
+
v-for="g in grades"
|
|
160
|
+
:key="g.id"
|
|
161
|
+
class="btn"
|
|
162
|
+
:class="{ on: graded && lut === g.id }"
|
|
163
|
+
@click="pickGrade(g.id)"
|
|
164
|
+
>
|
|
165
|
+
{{ g.label }}
|
|
166
|
+
</button>
|
|
167
|
+
</div>
|
|
168
|
+
<p class="faint">
|
|
169
|
+
The effect takes a lookup table as an image, url() in the CSS, and runs every pixel behind it through that
|
|
170
|
+
table. Switching tables cross-fades between the two grades.
|
|
171
|
+
</p>
|
|
172
|
+
</Card>
|
|
173
|
+
|
|
174
|
+
<Card title="Patterned glass" api="glass · sampleRepeat">
|
|
175
|
+
<div class="scene">
|
|
176
|
+
<div class="stripe s1" />
|
|
177
|
+
<div class="stripe s2" />
|
|
178
|
+
<div class="stripe s3" />
|
|
179
|
+
<div class="word under">texture</div>
|
|
180
|
+
<div class="pane" :style="{ '--shading': glass }" />
|
|
181
|
+
</div>
|
|
182
|
+
<div class="row">
|
|
183
|
+
<button v-for="p in patterns" :key="p.id" class="btn" :class="{ on: pattern.id === p.id }" @click="pattern = p">
|
|
184
|
+
{{ p.label }}
|
|
185
|
+
</button>
|
|
186
|
+
<span class="faint">A tiling normal map bends what is behind the pane.</span>
|
|
187
|
+
</div>
|
|
188
|
+
</Card>
|
|
189
|
+
|
|
190
|
+
<Card title="Spotlight" api="spotlight · [SkPointer]">
|
|
191
|
+
<div class="pad">
|
|
192
|
+
<span class="hint">move the pointer here</span>
|
|
193
|
+
</div>
|
|
194
|
+
<p class="faint">
|
|
195
|
+
The host hands the effect the pointer and repaints it as the pointer moves, so no script runs. The light dims as
|
|
196
|
+
the pointer leaves the panel.
|
|
197
|
+
</p>
|
|
198
|
+
</Card>
|
|
199
|
+
</Page>
|
|
200
|
+
</template>
|
|
201
|
+
|
|
202
|
+
<style scoped>
|
|
203
|
+
.scene {
|
|
204
|
+
position: relative;
|
|
205
|
+
z-index: 1;
|
|
206
|
+
height: 190px;
|
|
207
|
+
border-radius: 12px;
|
|
208
|
+
background: #0e0e16;
|
|
209
|
+
overflow: hidden;
|
|
210
|
+
}
|
|
211
|
+
@keyframes drift {
|
|
212
|
+
50% {
|
|
213
|
+
transform: translateX(120px);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
.blob {
|
|
217
|
+
position: absolute;
|
|
218
|
+
width: 120px;
|
|
219
|
+
height: 120px;
|
|
220
|
+
border-radius: 60px;
|
|
221
|
+
animation: drift 7s ease-in-out infinite;
|
|
222
|
+
}
|
|
223
|
+
.b1 {
|
|
224
|
+
left: 30px;
|
|
225
|
+
top: 20px;
|
|
226
|
+
background: #8b9dff;
|
|
227
|
+
}
|
|
228
|
+
.b2 {
|
|
229
|
+
left: 260px;
|
|
230
|
+
top: 60px;
|
|
231
|
+
background: #f472b6;
|
|
232
|
+
animation-duration: 9s;
|
|
233
|
+
}
|
|
234
|
+
.b3 {
|
|
235
|
+
left: 480px;
|
|
236
|
+
top: 10px;
|
|
237
|
+
background: #34d399;
|
|
238
|
+
animation-duration: 8s;
|
|
239
|
+
}
|
|
240
|
+
.word {
|
|
241
|
+
position: absolute;
|
|
242
|
+
left: 24px;
|
|
243
|
+
top: 58px;
|
|
244
|
+
font-size: 64px;
|
|
245
|
+
font-weight: 800;
|
|
246
|
+
color: #ffffffd9;
|
|
247
|
+
}
|
|
248
|
+
.lens {
|
|
249
|
+
position: absolute;
|
|
250
|
+
top: 30px;
|
|
251
|
+
width: 220px;
|
|
252
|
+
height: 130px;
|
|
253
|
+
display: flex;
|
|
254
|
+
align-items: flex-end;
|
|
255
|
+
justify-content: center;
|
|
256
|
+
padding-bottom: 12px;
|
|
257
|
+
border-radius: 36px;
|
|
258
|
+
font-size: 12px;
|
|
259
|
+
color: #ffffffb0;
|
|
260
|
+
cursor: grab;
|
|
261
|
+
--shading: lens(22px, 32px, 0.2, #ffffff0d);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.nebula {
|
|
265
|
+
height: 190px;
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: flex-end;
|
|
268
|
+
padding: 14px;
|
|
269
|
+
border-radius: 12px;
|
|
270
|
+
cursor: pointer;
|
|
271
|
+
--shading: nebula(0.1, 1.3, 0, #ffe6c7);
|
|
272
|
+
transition: --shading 1600ms ease;
|
|
273
|
+
}
|
|
274
|
+
.nebula.warm {
|
|
275
|
+
--shading: nebula(0.1, 1.3, 0.45, #fff1d6);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.orbits {
|
|
279
|
+
gap: 40px;
|
|
280
|
+
padding: 24px 28px;
|
|
281
|
+
}
|
|
282
|
+
.orbit-card {
|
|
283
|
+
width: 220px;
|
|
284
|
+
height: 110px;
|
|
285
|
+
display: flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
justify-content: center;
|
|
288
|
+
border-radius: 16px;
|
|
289
|
+
background: #ffffff05;
|
|
290
|
+
font-size: 13px;
|
|
291
|
+
color: var(--text-muted);
|
|
292
|
+
--shading: orbit(0.3, 2px, 24px, 0.4, #7fd4ff);
|
|
293
|
+
}
|
|
294
|
+
.orbit-pill {
|
|
295
|
+
height: 44px;
|
|
296
|
+
padding: 0 26px;
|
|
297
|
+
border: none;
|
|
298
|
+
border-radius: 22px;
|
|
299
|
+
background: #ffffff08;
|
|
300
|
+
font-size: 14px;
|
|
301
|
+
font-weight: 600;
|
|
302
|
+
color: var(--text);
|
|
303
|
+
--shading: orbit(0.55, 1.5px, 16px, 0.3, #ff8ad4);
|
|
304
|
+
}
|
|
305
|
+
.orbit-ring {
|
|
306
|
+
width: 96px;
|
|
307
|
+
height: 96px;
|
|
308
|
+
display: flex;
|
|
309
|
+
align-items: center;
|
|
310
|
+
justify-content: center;
|
|
311
|
+
border-radius: 48px;
|
|
312
|
+
font-size: 12px;
|
|
313
|
+
color: var(--text-faint);
|
|
314
|
+
--shading: orbit(0.9, 3px, 28px, 0.25, #fbbf24);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.print {
|
|
318
|
+
position: relative;
|
|
319
|
+
z-index: 1;
|
|
320
|
+
height: 220px;
|
|
321
|
+
border-radius: 12px;
|
|
322
|
+
overflow: hidden;
|
|
323
|
+
}
|
|
324
|
+
.photo {
|
|
325
|
+
width: 100%;
|
|
326
|
+
height: 220px;
|
|
327
|
+
object-fit: cover;
|
|
328
|
+
}
|
|
329
|
+
.screen {
|
|
330
|
+
position: absolute;
|
|
331
|
+
top: 0;
|
|
332
|
+
right: 0;
|
|
333
|
+
bottom: 0;
|
|
334
|
+
width: 50%;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.ticket {
|
|
338
|
+
display: flex;
|
|
339
|
+
width: 360px;
|
|
340
|
+
height: 120px;
|
|
341
|
+
border-radius: 14px;
|
|
342
|
+
background: #1b1b28;
|
|
343
|
+
overflow: hidden;
|
|
344
|
+
--shading: dissolve(0, 46px);
|
|
345
|
+
transition: --shading 1800ms ease-in;
|
|
346
|
+
}
|
|
347
|
+
.ticket.burnt {
|
|
348
|
+
--shading: dissolve(1, 46px);
|
|
349
|
+
transition-timing-function: ease-out;
|
|
350
|
+
}
|
|
351
|
+
.ticket-photo {
|
|
352
|
+
width: 120px;
|
|
353
|
+
height: 120px;
|
|
354
|
+
object-fit: cover;
|
|
355
|
+
}
|
|
356
|
+
.ticket-text {
|
|
357
|
+
display: flex;
|
|
358
|
+
flex-direction: column;
|
|
359
|
+
justify-content: center;
|
|
360
|
+
gap: 6px;
|
|
361
|
+
padding: 0 20px;
|
|
362
|
+
font-size: 13px;
|
|
363
|
+
color: var(--text-muted);
|
|
364
|
+
}
|
|
365
|
+
.ticket-text strong {
|
|
366
|
+
font-size: 18px;
|
|
367
|
+
color: var(--text);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.pond {
|
|
371
|
+
position: relative;
|
|
372
|
+
height: 220px;
|
|
373
|
+
border-radius: 12px;
|
|
374
|
+
overflow: hidden;
|
|
375
|
+
--shading: pond(0.985, 40px);
|
|
376
|
+
}
|
|
377
|
+
.pond-photo {
|
|
378
|
+
width: 100%;
|
|
379
|
+
height: 220px;
|
|
380
|
+
object-fit: cover;
|
|
381
|
+
}
|
|
382
|
+
.pond-word {
|
|
383
|
+
position: absolute;
|
|
384
|
+
left: 24px;
|
|
385
|
+
bottom: 18px;
|
|
386
|
+
font-size: 44px;
|
|
387
|
+
font-weight: 800;
|
|
388
|
+
color: #ffffffe0;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.graded {
|
|
392
|
+
position: absolute;
|
|
393
|
+
top: 0;
|
|
394
|
+
right: 0;
|
|
395
|
+
bottom: 0;
|
|
396
|
+
left: 0;
|
|
397
|
+
transition: --shading 700ms ease;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.stripe {
|
|
401
|
+
position: absolute;
|
|
402
|
+
top: 0;
|
|
403
|
+
bottom: 0;
|
|
404
|
+
width: 70px;
|
|
405
|
+
}
|
|
406
|
+
.s1 {
|
|
407
|
+
left: 60px;
|
|
408
|
+
background: #8b9dff;
|
|
409
|
+
}
|
|
410
|
+
.s2 {
|
|
411
|
+
left: 220px;
|
|
412
|
+
background: #f472b6;
|
|
413
|
+
}
|
|
414
|
+
.s3 {
|
|
415
|
+
left: 380px;
|
|
416
|
+
background: #fbbf24;
|
|
417
|
+
}
|
|
418
|
+
.word.under {
|
|
419
|
+
left: 180px;
|
|
420
|
+
}
|
|
421
|
+
.pane {
|
|
422
|
+
position: absolute;
|
|
423
|
+
top: 0;
|
|
424
|
+
right: 0;
|
|
425
|
+
bottom: 0;
|
|
426
|
+
width: 55%;
|
|
427
|
+
border-left: 1px solid #ffffff1f;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.pad {
|
|
431
|
+
height: 200px;
|
|
432
|
+
display: flex;
|
|
433
|
+
align-items: flex-end;
|
|
434
|
+
padding: 14px;
|
|
435
|
+
border-radius: 12px;
|
|
436
|
+
background: #0e0e16;
|
|
437
|
+
--shading: spotlight(150px, 1, #8b9dff);
|
|
438
|
+
}
|
|
439
|
+
.hint {
|
|
440
|
+
font-size: 12px;
|
|
441
|
+
color: #ffffff8c;
|
|
442
|
+
}
|
|
443
|
+
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Route components are static imports: the runtime loads one bundle, so there is no lazy `() => import()`.
|
|
2
2
|
import { createMemoryHistory, createRouter } from "vue-router";
|
|
3
|
-
import type
|
|
3
|
+
import { nextTick, type Component } from "vue";
|
|
4
4
|
import type { IconName } from "./icons";
|
|
5
5
|
import AudioPage from "./pages/AudioPage.vue";
|
|
6
6
|
import FilesPage from "./pages/FilesPage.vue";
|
|
@@ -12,6 +12,7 @@ import MediaPage from "./pages/MediaPage.vue";
|
|
|
12
12
|
import MotionPage from "./pages/MotionPage.vue";
|
|
13
13
|
import NetworkPage from "./pages/NetworkPage.vue";
|
|
14
14
|
import PermissionsPage from "./pages/PermissionsPage.vue";
|
|
15
|
+
import ShadersPage from "./pages/ShadersPage.vue";
|
|
15
16
|
import StoragePage from "./pages/StoragePage.vue";
|
|
16
17
|
import StylesPage from "./pages/StylesPage.vue";
|
|
17
18
|
import SystemPage from "./pages/SystemPage.vue";
|
|
@@ -109,6 +110,14 @@ export const pages: PageEntry[] = [
|
|
|
109
110
|
blurb: "Canvas 2D drawing and a WebGPU shader",
|
|
110
111
|
component: GraphicsPage,
|
|
111
112
|
},
|
|
113
|
+
{
|
|
114
|
+
path: "/shaders",
|
|
115
|
+
title: "Shaders",
|
|
116
|
+
icon: "shaders",
|
|
117
|
+
section: "Media",
|
|
118
|
+
blurb: "Liquid glass, nebula, halftone: the app's own GPU effects in CSS",
|
|
119
|
+
component: ShadersPage,
|
|
120
|
+
},
|
|
112
121
|
{
|
|
113
122
|
path: "/motion",
|
|
114
123
|
title: "Motion",
|
|
@@ -147,3 +156,25 @@ export const router = createRouter({
|
|
|
147
156
|
history: createMemoryHistory(),
|
|
148
157
|
routes: pages.map(({ path, component }) => ({ path, component })),
|
|
149
158
|
});
|
|
159
|
+
|
|
160
|
+
// Every navigation is a view transition: the route resolves once the old page is captured, and the
|
|
161
|
+
// update ends when Vue has rendered the new one.
|
|
162
|
+
let rendered: (() => void) | undefined;
|
|
163
|
+
router.beforeResolve(
|
|
164
|
+
(to, from) =>
|
|
165
|
+
to.path === from.path ||
|
|
166
|
+
new Promise<void>((proceed) => {
|
|
167
|
+
document.startViewTransition(
|
|
168
|
+
() =>
|
|
169
|
+
new Promise<void>((done) => {
|
|
170
|
+
rendered = done;
|
|
171
|
+
proceed();
|
|
172
|
+
}),
|
|
173
|
+
);
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
176
|
+
router.afterEach(async () => {
|
|
177
|
+
await nextTick();
|
|
178
|
+
rendered?.();
|
|
179
|
+
rendered = undefined;
|
|
180
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello from assets/hello.txt, packaged with {{productName}}.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
|
|
4
|
+
const productName = "{{productName}}";
|
|
5
|
+
const initial = productName.charAt(0).toUpperCase();
|
|
6
|
+
|
|
7
|
+
let count = $state(0);
|
|
8
|
+
const clicks = $derived(`${count} ${count === 1 ? "click" : "clicks"}`);
|
|
9
|
+
|
|
10
|
+
// A relative URL resolves against the app root in dev and against the packaged assets in a build.
|
|
11
|
+
let greeting = $state("");
|
|
12
|
+
onMount(async () => {
|
|
13
|
+
if (typeof fetch !== "function") return;
|
|
14
|
+
const res = await fetch("assets/hello.txt");
|
|
15
|
+
if (res.ok) greeting = (await res.text()).trim();
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<main class="page">
|
|
20
|
+
<section class="card">
|
|
21
|
+
<div class="logo">{initial}</div>
|
|
22
|
+
<h1 class="title">{productName}</h1>
|
|
23
|
+
<p class="lead">Svelte on a native GPU renderer. Edit <span class="code">src/App.svelte</span> and save.</p>
|
|
24
|
+
<div class="actions">
|
|
25
|
+
<button class="button" onclick={() => count++}>Count up</button>
|
|
26
|
+
<button class="button ghost" disabled={count === 0} onclick={() => (count = 0)}>Reset</button>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="count">{clicks}</div>
|
|
29
|
+
</section>
|
|
30
|
+
{#if greeting}
|
|
31
|
+
<p class="hint">{greeting}</p>
|
|
32
|
+
{/if}
|
|
33
|
+
</main>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
.page {
|
|
37
|
+
height: 100%;
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
gap: 20px;
|
|
43
|
+
padding: 32px;
|
|
44
|
+
color: #f4f4f5;
|
|
45
|
+
font-family: system-ui, sans-serif;
|
|
46
|
+
}
|
|
47
|
+
.card {
|
|
48
|
+
width: 380px;
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: 14px;
|
|
53
|
+
padding: 36px 32px 28px;
|
|
54
|
+
border-radius: 20px;
|
|
55
|
+
background: #18181bb3;
|
|
56
|
+
border: 1px solid #ffffff14;
|
|
57
|
+
box-shadow: 0 24px 60px #00000066;
|
|
58
|
+
}
|
|
59
|
+
.logo {
|
|
60
|
+
width: 64px;
|
|
61
|
+
height: 64px;
|
|
62
|
+
border-radius: 18px;
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
font-size: 30px;
|
|
67
|
+
font-weight: 700;
|
|
68
|
+
color: #ffffff;
|
|
69
|
+
background: linear-gradient(135deg, #ff3e00, #ff8a3d);
|
|
70
|
+
box-shadow: 0 10px 28px #ff3e0055;
|
|
71
|
+
animation: float 4s ease-in-out infinite;
|
|
72
|
+
}
|
|
73
|
+
@keyframes float {
|
|
74
|
+
50% {
|
|
75
|
+
transform: translateY(-5px);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.title {
|
|
79
|
+
margin: 0;
|
|
80
|
+
font-size: 26px;
|
|
81
|
+
font-weight: 700;
|
|
82
|
+
}
|
|
83
|
+
.lead {
|
|
84
|
+
margin: 0;
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
line-height: 21px;
|
|
87
|
+
color: #a1a1aa;
|
|
88
|
+
text-align: center;
|
|
89
|
+
}
|
|
90
|
+
.code {
|
|
91
|
+
font-family: monospace;
|
|
92
|
+
font-size: 13px;
|
|
93
|
+
color: #d4d4d8;
|
|
94
|
+
}
|
|
95
|
+
.actions {
|
|
96
|
+
display: flex;
|
|
97
|
+
gap: 10px;
|
|
98
|
+
margin-top: 8px;
|
|
99
|
+
}
|
|
100
|
+
.button {
|
|
101
|
+
padding: 9px 20px;
|
|
102
|
+
border-radius: 10px;
|
|
103
|
+
border-width: 0;
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
color: #ffffff;
|
|
107
|
+
background: linear-gradient(135deg, #ff3e00, #ff8a3d);
|
|
108
|
+
box-shadow: 0 6px 18px #ff3e0040;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
transition:
|
|
111
|
+
transform 120ms ease,
|
|
112
|
+
box-shadow 120ms ease;
|
|
113
|
+
}
|
|
114
|
+
.button:hover {
|
|
115
|
+
transform: translateY(-1px);
|
|
116
|
+
box-shadow: 0 10px 24px #ff3e0066;
|
|
117
|
+
}
|
|
118
|
+
.button:active {
|
|
119
|
+
transform: scale(0.97);
|
|
120
|
+
}
|
|
121
|
+
.button.ghost {
|
|
122
|
+
color: #d4d4d8;
|
|
123
|
+
background: #ffffff10;
|
|
124
|
+
box-shadow: none;
|
|
125
|
+
}
|
|
126
|
+
.button.ghost:hover {
|
|
127
|
+
background: #ffffff1c;
|
|
128
|
+
}
|
|
129
|
+
.button:disabled {
|
|
130
|
+
opacity: 0.4;
|
|
131
|
+
cursor: default;
|
|
132
|
+
}
|
|
133
|
+
.count {
|
|
134
|
+
font-size: 13px;
|
|
135
|
+
color: #71717a;
|
|
136
|
+
}
|
|
137
|
+
.hint {
|
|
138
|
+
margin: 0;
|
|
139
|
+
font-size: 12px;
|
|
140
|
+
color: #71717a;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
package/vitecompat.ts
CHANGED
|
@@ -666,6 +666,8 @@ export function viteShapesPlugin(o: ShapesOptions) {
|
|
|
666
666
|
return { contents: wasmStubModule(idOf(args.path), new Set()), loader: "js" };
|
|
667
667
|
});
|
|
668
668
|
build.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, async (args: Bun.OnLoadArgs) => {
|
|
669
|
+
// A Svelte rune module is the Svelte plugin's to compile.
|
|
670
|
+
if (/\.svelte\.[jt]s$/.test(args.path)) return undefined;
|
|
669
671
|
const src = await Bun.file(args.path).text();
|
|
670
672
|
const code =
|
|
671
673
|
src.includes("import.meta.glob") || src.includes("new URL") ? transformSource(src, args.path, o) : null;
|