@skathi-native/cli 0.1.0-beta.4 → 0.3.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.
Files changed (63) hide show
  1. package/aot/host-globals.json +1 -1
  2. package/aot/pin.ts +1 -1
  3. package/aot/toolchain.lock.json +5 -5
  4. package/aot/transform.ts +9 -1
  5. package/aot-inputs.ts +21 -2
  6. package/build.ts +284 -64
  7. package/check/builtins.json +11 -11
  8. package/check/bundle.ts +265 -0
  9. package/check/codes.ts +46 -0
  10. package/check/css-catalog.json +451 -0
  11. package/check/css.ts +512 -0
  12. package/check/finding.ts +63 -1
  13. package/check/graph.ts +14 -1
  14. package/check/index.ts +30 -49
  15. package/check/program.ts +26 -6
  16. package/cli/aot-build.ts +2 -6
  17. package/cli/build-app.ts +19 -0
  18. package/cli/create.ts +70 -12
  19. package/cli/dev.ts +11 -6
  20. package/cli/effects.ts +39 -18
  21. package/cli/gallery.ts +106 -0
  22. package/cli/sk.ts +5 -2
  23. package/devtools/commands.ts +26 -1
  24. package/devtools/ctl.ts +4 -3
  25. package/effects/compile.ts +160 -31
  26. package/effects/sk.slang +359 -30
  27. package/gallery.json +1 -0
  28. package/package.json +9 -5
  29. package/prod.ts +78 -10
  30. package/svelte.ts +76 -0
  31. package/templates/icon.png +0 -0
  32. package/templates/showcase/assets/textures/golden.png +0 -0
  33. package/templates/showcase/assets/textures/hammered.png +0 -0
  34. package/templates/showcase/assets/textures/noir.png +0 -0
  35. package/templates/showcase/assets/textures/reeded.png +0 -0
  36. package/templates/showcase/assets/textures/teal-orange.png +0 -0
  37. package/templates/showcase/shaders/dissolve.slang +40 -0
  38. package/templates/showcase/shaders/fireflies.slang +58 -0
  39. package/templates/showcase/shaders/glass.slang +31 -0
  40. package/templates/showcase/shaders/grade.slang +34 -0
  41. package/templates/showcase/shaders/halftone.slang +42 -0
  42. package/templates/showcase/shaders/lens.slang +51 -0
  43. package/templates/showcase/shaders/nebula.slang +57 -0
  44. package/templates/showcase/shaders/orbit.slang +52 -0
  45. package/templates/showcase/shaders/pond.slang +76 -0
  46. package/templates/showcase/shaders/ripples.slang +71 -0
  47. package/templates/showcase/shaders/shatter.slang +116 -0
  48. package/templates/showcase/shaders/snow.slang +57 -0
  49. package/templates/showcase/shaders/spotlight.slang +52 -0
  50. package/templates/showcase/src/App.vue +11 -16
  51. package/templates/showcase/src/components/FullWindow.vue +77 -0
  52. package/templates/showcase/src/components/Page.vue +2 -0
  53. package/templates/showcase/src/fullwindow.ts +36 -0
  54. package/templates/showcase/src/icons.ts +2 -0
  55. package/templates/showcase/src/pages/GraphicsPage.vue +122 -0
  56. package/templates/showcase/src/pages/MotionPage.vue +71 -1
  57. package/templates/showcase/src/pages/ShadersPage.vue +443 -0
  58. package/templates/showcase/src/router.ts +32 -1
  59. package/templates/svelte/.vscode/settings.json +3 -0
  60. package/templates/svelte/assets/hello.txt +1 -0
  61. package/templates/svelte/src/App.svelte +142 -0
  62. package/templates/svelte/src/main.ts +4 -0
  63. package/vitecompat.ts +2 -0
@@ -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 { Component } from "vue";
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,3 @@
1
+ {
2
+ "css.customData": ["./node_modules/@skathi-native/runtime/css-data.json"]
3
+ }
@@ -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>
@@ -0,0 +1,4 @@
1
+ import { mount } from "@skathi-native/runtime/svelte";
2
+ import App from "./App.svelte";
3
+
4
+ mount(App);
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;